﻿# coding: utf-8

import wx
import Property

class wxPanelProperty(wx.Panel):
    
    __ID_PROP_NULL = wx.NewId()
    __ID_PROP_BUILD_SINGLE = wx.NewId()
    __ID_PROP_PARTICLE_EMITTER = wx.NewId()
    __ID_PROP_MODIFIER = wx.NewId()
    __ID_PROP_PARTICLE_TEXTURE = wx.NewId()
    __ID_PROP_POST_PROCESS = wx.NewId()
    __ID_PROP_MATERIAL = wx.NewId()
    __ID_PROP_SCENE_LIGHT = wx.NewId()
    
    __PANEL_CREATE_DICT = [
        {'id' : __ID_PROP_NULL, 'name' : 'PANEL_PROP_NULL', 'class' : Property.wxPanelPropertyNull},
        {'id' : __ID_PROP_BUILD_SINGLE, 'name' : 'PANEL_PROP_BUILD_SINGLE', 'class' : Property.wxPanelPropertyBuildSingle},
        {'id' : __ID_PROP_PARTICLE_EMITTER, 'name' : 'PANEL_PROP_PARTICLE_EMITTER', 'class' : Property.wxPanelPropertyParticleEmitter},
        {'id' : __ID_PROP_MODIFIER, 'name' : 'PANEL_PROP_MODIFIER', 'class' : Property.wxPanelPropertyModifier},
        {'id' : __ID_PROP_PARTICLE_TEXTURE, 'name' : 'PANEL_PROP_PARTICLE_TEXTURE', 'class' : Property.wxPanelPropertyParticleTexture},
        {'id' : __ID_PROP_POST_PROCESS, 'name' : 'PANEL_PROP_POST_PROCESS', 'class' : Property.wxPanelPropertyPostProcess},
        {'id' : __ID_PROP_MATERIAL, 'name' : 'PANEL_PROP_MATERIAL', 'class' : Property.wxPanelPropertyMaterial},
        {'id' : __ID_PROP_SCENE_LIGHT, 'name' : 'PANEL_PROP_SCENE_LIGHT', 'class' : Property.wxPanelPropertySceneLight},
    ]
    
    def __init__(self, parent, id):
        """ Default class constructor """
        
        wx.Panel.__init__(self, parent, id)
        
        self._panelPropList = []
        
        for item in wxPanelProperty.__PANEL_CREATE_DICT:
            id = item['id']
            name = item['name']
            classType = item['class']
            panel = classType(self, id)
            __builtins__[name] = panel
            panel.Show(False)
            self._panelPropList.append(panel)
            panel.SetAutoLayout(1)
            panel.SetupScrolling()
        
        self._currentPanel = PANEL_PROP_NULL
        self.SetPanelProperty(PANEL_PROP_NULL)
            
    def SetPanelProperty(self, panel):
        """ Show specified property in property panel """
        
        self._currentPanel.Show(False)
        self._currentPanel = panel
        self._currentPanel.Show(True)
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(panel, 1, wx.EXPAND|wx.ALL, 0)
        self.SetSizer(sizer)
        self.Layout()